package sdfi.lee.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sdfi.lee.DAO.QuestionDAO;
import sdfi.lee.Logger.MyLogger;
import sdfi.lee.Question.Relation;

/**
 * Servlet implementation class GetRelation
 */
public class GetRelation extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GetRelation() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String documentid=request.getParameter("documentid");
		String enname=request.getParameter("nename");
	
		QuestionDAO dao=new QuestionDAO();
		StringBuffer bs=new StringBuffer();
		try
		{
				bs.append(dao.getRelation(documentid,enname));
				response.setCharacterEncoding("utf-8");
				PrintWriter pw=((HttpServletResponse)response).getWriter();
				
				pw.append(bs.toString());
				pw.flush();
			
		}
		catch(Exception ee)
		{
			MyLogger.Logger(ee.getMessage(), null, "error");
			
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(request, response);
	}

}
